const mysql = require('mysql2/promise');

const db = mysql.createPool({
  host: '192.168.40.1',
  user: 'remote_user',
  password: '223344',
  database: 'examdb',
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0
});

// 测试连接，88b0e1a9477b4b0638f4d4038dd9e3cb
async function testConnection() {
  try {
    const connection = await db.getConnection()
    console.log('数据库连接成功')
    connection.release()
  } catch (err) {
    console.error('数据库连接失败:', err)
  }
}

testConnection()

module.exports = db